﻿using FastCtr;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class InjectForeForm : Form
    {
        public InjectForeForm()
        {
            InitializeComponent();
        }

        AxNewSerialPort axNewSerialPort = new AxNewSerialPort("myAXport2333");

        private void timer1_Tick(object sender, EventArgs e)
        {
            label11.Text = GlobalValues.DeviceNo.Value;
            label27.Text = GlobalValues.BarCode;
            label22.Text = GlobalValues.DeviceNo.Value;
            label23.Text = GlobalValues.UserName;
            textBox4.Text = GlobalValues.DeviceNo.Value;
        }


        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.TextLength == 10)
            {
                textBox1.SelectAll();
                GlobalValues.BarCode = textBox1.Text;
            }
        }

        private void textBox5_Validated(object sender, EventArgs e)
        {
            GlobalValues.UserName = textBox5.Text;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form form = new Form();
            form.Controls.Add(axNewSerialPort);
            form.ShowDialog();
        }

        private void InjectForeForm_Load(object sender, EventArgs e)
        {
            axNewSerialPort.Open();
            if (axNewSerialPort.IsOpen)
            {
                Text = "串口已经打开 -- " + axNewSerialPort.Setting._port;
            }
            else
            {
                Text = "串口打开失败！ -- " + axNewSerialPort.Setting._port;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
            //Form form = new Form();
            //form.Controls.Add(GlobalValues.omroPLC);
            //form.Show();
        }
    }
}
